ostree: Use #defines for well-known metadata key names
authorPhilip Withnall <withnall@endlessm.com>
Fri, 5 May 2017 10:28:42 +0000 (11:28 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 8 May 2017 00:55:24 +0000 (00:55 +0000)
Rather than hard-coding the names as strings. This makes the code a
little more maintainable.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #826
Approved by: cgwalters

src/ostree/ot-builtin-gpg-sign.c
src/ostree/ot-dump.c

index 0ef2be8b99ed399ddf8a9a83f85f2c335ce6738c..e14eba686c7b37aa9a7085099e8f77e41f92d78b 100644 (file)
@@ -26,6 +26,7 @@
 #include "ot-builtins.h"
 #include "ostree.h"
 #include "otutil.h"
+#include "ostree-core-private.h"
 
 static gboolean opt_delete;
 static char *opt_gpg_homedir;
@@ -85,7 +86,7 @@ delete_signatures (OstreeRepo *repo,
   g_variant_dict_init (&metadata_dict, old_metadata);
 
   signature_data = g_variant_dict_lookup_value (&metadata_dict,
-                                                "ostree.gpgsigs",
+                                                _OSTREE_METADATA_GPGSIGS_NAME,
                                                 G_VARIANT_TYPE ("aay"));
 
   /* Taking the approach of deleting whatever matches we find for the
@@ -154,7 +155,7 @@ delete_signatures (OstreeRepo *repo,
   /* Update the metadata dictionary. */
   if (g_queue_is_empty (&signatures))
     {
-      g_variant_dict_remove (&metadata_dict, "ostree.gpgsigs");
+      g_variant_dict_remove (&metadata_dict, _OSTREE_METADATA_GPGSIGS_NAME);
     }
   else
     {
@@ -170,7 +171,7 @@ delete_signatures (OstreeRepo *repo,
         }
 
       g_variant_dict_insert_value (&metadata_dict,
-                                   "ostree.gpgsigs",
+                                   _OSTREE_METADATA_GPGSIGS_NAME,
                                    g_variant_builder_end (&signature_builder));
     }
 
index 7cbc2945ee82da8d57637753e1a133b8723658eb..b24003c73a8bfadc4391d7cbeebe6a48084da0d0 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <err.h>
 
+#include "ostree-repo-private.h"
+#include "ostree-repo-static-delta-private.h"
 #include "ot-dump.h"
 #include "otutil.h"
 #include "ot-admin-functions.h"
@@ -268,17 +270,17 @@ ot_dump_summary_bytes (GBytes          *summary_bytes,
       g_autofree gchar *value_str = NULL;
       const gchar *pretty_key = NULL;
 
-      if (g_strcmp0 (key, "ostree.static-deltas") == 0)
+      if (g_strcmp0 (key, OSTREE_SUMMARY_STATIC_DELTAS) == 0)
         {
           pretty_key = "Static Deltas";
           value_str = g_variant_print (value, FALSE);
         }
-      else if (g_strcmp0 (key, "ostree.summary.last-modified") == 0)
+      else if (g_strcmp0 (key, OSTREE_SUMMARY_LAST_MODIFIED) == 0)
         {
           pretty_key = "Last-Modified";
           value_str = uint64_secs_to_iso8601 (GUINT64_FROM_BE (g_variant_get_uint64 (value)));
         }
-      else if (g_strcmp0 (key, "ostree.summary.expires") == 0)
+      else if (g_strcmp0 (key, OSTREE_SUMMARY_EXPIRES) == 0)
         {
           pretty_key = "Expires";
           value_str = uint64_secs_to_iso8601 (GUINT64_FROM_BE (g_variant_get_uint64 (value)));